<? /* license

BilugCMS (http://www.bilug.it) - Content Management System for dynamic web sites
Copyright (C) 2005-2008  Federico Villa and Alessio Loro Piana

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

For reference, contact bilugcms@vilnet.it


license */ ?>

<html>
<head>
<link rel="stylesheet" type="text/css" href="./utility/cssstile	.css"/>

<style>
.contenitore{
width: 600px;
margin: 40px auto;
}

#install{
margin: 20px;
font-size: 25px;
color: #ffac0b;
text-shadow: 3px 3px 6px #000;
}
</style>
</head>

<body>
<?
//concatenazione parti fisse e variabili
function concatenazione($username,$pass,$dbname)
{
	$licenza = "<? /* license

BilugCMS (http://www.bilug.it) - Content Management System for dynamic web sites
Copyright (C) 2005-2008  Federico Villa and Alessio Loro Piana

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

For reference, contact bilugcms@vilnet.it\n

license */ ?> \n";	
	
	$variabile = "<?
	\n\$host=\"\$localhost\";\n// si mette localhost perchè il mysql risiede sulla stessa macchina dell'apache\n\$username=\"$username\";\n\$pass=\"$pass\";\n\$dbname=\"$dbname\";\n";
					
	$controllo = "\$connect = mysql_connect(\$host, \$username, \$pass);\n// se si mette @mysql_connect, cioè la @ davanti, inibisce i messaggi di errore\n// mysql_select come lo fa Alberto\n\$controllo=mysql_select_db(\$dbname,\$connect) or die (\"Attenzione, non è possibile connettersi al DB\");\n// mysql_select come la fa Davide\n//mysql_select_db (\$dbname);\n 
	?>";
	
	$conc = "".$licenza."".$variabile."".$controllo."";
	return $conc;
}


//controllo se siamo in fase di inserimento o di script(install)
$script=null;
$script=$_POST["script"];
if ($script!="ok")
{
	?>
		<h2 id="install">Inserimento dati per Installazione DB Cms</h2>
		<br><br>
		<div class="contenitore"><div class="azzerafloat"></div>
		<form name="install" method="post" action="install.php" enctype="multipart/form-data">
		<input type="hidden" name="script" value="ok">
		<div class="float100"> <h1>Username: </h1> </div>
		<div class="float100"> <input type="text" name="username"> </div>
		<br><br>
		<div class="float100"> <h1>Password: </h1> </div>
		<div class="float100"> <input type="password" name="pass"> </div>
		<br><br>
		<div class="float100"> <h1>Nome DB: </h1> </div>
		<div class="float100"> <input type="text" name="dbname"> </div>
		<br><br><br>
		<input type="submit" value=".:send:.">
		</form>
		</div>
	<?
}
else
{
	//si esegue lo script
	// si raccoglie tutti i dati 	
	$username=$_POST["username"];
	$pass=$_POST["pass"];
	$dbname=$_POST["dbname"];
	
	//si scrive nel file utility/connessione.php
	$filename= "./utility/connessione.php";
	//apro il file con w cosi sn sicuro che all'apertura sia vuoto.
	$file = fopen("$filename","w+");
	//funzione di concatenazione parti fisse e variabili
	$scritta=concatenazione($username,$pass,$dbname);
	//scrittura nel file
	$scrittura=fwrite($file,$scritta);
	if($scrittura)
	{
		?>
				<div class="contenitore"><div class="azzerafloat"></div>
				<h2 id="install">File di connessione generato !</h2>
				</div>
		<?
		
	}
	else
	{
		?>
				<div class="contenitore"><div class="azzerafloat"></div>
				<h2 id="install">Errore nel file di connessione</h2>
				</div>
		<?
		
	}
	//chiusura file	
	@fclose($file);
	
	
	
	//ora procediamo con la creazione delle tabelle
	//connessione
	//@include ("./utility/connessione2.php");	
	
	//importazione
	Header("Location: ./bigdump.php?dbname=$dbname&pass=$pass&username=$username&start=1&fn=bilug.sql&foffset=0&totalqueries=0");
	
}


?>
</body>
</html>
